package factory;

public class CarSimpleFactory {

    public static Audi createAudi(){
        return new Audi();
    }

    public static Benz createBenz(){
        return new Benz();
    }

    public static Car createCar(String type) throws IllegalAccessException,
            InstantiationException, ClassNotFoundException {
//        if("audi".equalsIgnoreCase(type)){
//            return Audi.class.newInstance();
//        }else if("benz".equalsIgnoreCase(type)){
//            return Benz.class.newInstance();
//        }else{
//            return null;
//        }
        return (Car)Class.forName(CarSimpleFactory.class.getPackage().getName() + "." + type).newInstance();
    }
}
